var judge=true;
var layer;
layui.use('layer', function(){
	layer = layui.layer;
	});
/*layui.use('form', function(){
  var form = layui.form;
  form.verify({
		//密码的验证
	    pwd: function (value, item) {
	        var pwd = $('#password').val();
	        if(pwd !=value){
	        	judge=false;
	        	layer.msg("两次输入密码不一致") ;
	        }else{
	        	judge=true;
	        }
	    },
	    email1: function (value, item) {
				  if(!(/^1([358][0-9]|4[579]|66|7[0135678]|9[89])[0-9]{8}$/.test(value))&&!(/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/.test(value))){
			      judge=false;
			      layer.msg('手机/邮箱错误');
			   }else{
	        	judge=true;
	        }
	    },
	});
	$("#zc").click(function(){
		//im();
		
		if($(this).attr("kg")=="yes"&&judge!==false)
		{
			
				$.ajax({
					type:"post",
					url:"/ajax.php?ajax=zhuce",
					data:{
						nickname:$("#nickname").val(),
						pwd:$("#password").val(),
						mailbox:$("#mailbox").val()
					},
					dataType:'json',
					success:function(mgs){
						console.log(judge);
						layer.msg(mgs.info); 
					}
				});
		}
	});
});*/
function dl(obj)
{
	window.location.href="/sy.php";
}




$(document).ready(function(){
	$.ajax({
					type:"post",
					url:"tiaodl.php",
					data:{
						code:$("#div1>div:nth-child(3)").attr("code")
					},
					dataType:"json",
					success:function(msg){
						console.log(msg);
					}
				});
	
	
	
$("#zc").click(function(){
		var pwd = $('#password').val();
		var value=$("#password1").val();
	        if(pwd !=value){
	        	judge=false;
	        	layer.msg("两次输入密码不一致");
	        	return;
	        }else{
	        	judge=true;
	        	$(this).attr("zzb")=="yes";
	        }
		
		
		
		var value1=$("#mailbox").val();
		var z=/^1([358][0-9]|4[579]|66|7[0135678]|9[89])[0-9]{8}$/;
		var z1=/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		if(z.test(value1)||z1.test(value1)){
				judge=true;
				$(this).attr("zzb")=="yes";
	        	//layer.msg(judge);
			   }else{
	        	judge=false;
			      layer.msg('手机/邮箱错误');
			      return;
	       }
		
		
		var kg=$(this).attr("kg");
		var zzb=$(this).attr("zzb");
		if(kg=="yes"&&zzb=="yes")
		{
				$.ajax({
					type:"post",
					url:"/ajax.php?ajax=zhuce",
					data:{
						nickname:$("#nickname").val(),
						pwd:$("#password").val(),
						mailbox:$("#mailbox").val()
					},
					dataType:"json",
					success:function(mgs){
						console.log(mgs);
						layer.msg(mgs.info); 
					}
				});
		}
		/*$.ajax({
					type:"post",
					url:"/ajax.php?ajax=zhuce",
					data:{
						nickname:$("#nickname").val(),
						pwd:$("#password").val(),
						mailbox:$("#mailbox").val()
					},
					dataType:"json",
					success:function(mgs){
						alert(mgs.info); 
					}
				});*/
	});

	
	
	
	var myCaptcha = _dx.Captcha(document.getElementById('c1'), {
				    appId: '9be12d3c3104f8574fdd5d545f715df8', //appId，在控制台中“应用管理”或“应用配置”模块获取
				    success: function (token) {
				      //console.log('token:', token)
				      $.ajax({
				      	type:"get",
				      	//url:"/Xphp/CaptchaDemo.php?token="+token,
				      	url:"/yzm.php?token="+token,
				      	success:function(msg){
				      		console.log(msg);
				      		if(msg=='SERVER_SUCCESStrue')
				      		{
				      			$("#zc").attr("kg","yes");
				      			$("#tj").css("display","none");
				      			$("#zc").css("background", "rgb(189,13,24)");
				      			$("#zc").css("color", "white");
				      			
				      		}
				      	}
				      });
				    }
				})
	$("#yzbtn").click(function(){
		//$("#c1").css("display","block");
		
		$("#tj").css("display","block");
	});
	
	$("#tj_1_1_1").click(function(){
		$("#tj").css("display", "none");
	});
});